package org.example.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.example.enums.service.MqttChannelService;
import org.example.utils.ExecutorsFactory;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.channel.ExecutorChannel;
import org.springframework.messaging.MessageChannel;

@Getter
@AllArgsConstructor
public enum MqttChannelTypeEnum implements MqttChannelService {
    DIRECT("DirectChannel", "mqtt单一通道"){
        @Override
        public MessageChannel build(String name) {
            return new DirectChannel();
        }
    },
    EXECUTOR("ExecutorChannel", "mqtt多消费通道"){
        @Override
        public MessageChannel build(String name) {
            return new ExecutorChannel(ExecutorsFactory.newIoInstance(name, null, null, true));
        }
    },
    ;

    private final String code;

    private final String desc;
}
